<?php
/*
 * @Date: 2021-04-25 22:48:07
 * @Author: yukun
 * @LastEditors: yukun
 * @LastEditTime: 2021-04-25 23:43:26
 * @FilePath: /design-patterns-study/策略模式/Order.php
 * @Description: 本文件主要功能为：
 */
class Order
{
    private $chanleObj;

    public function __construct(string $chanle)
    {
        try {
            $class = new ReflectionClass($chanle);
            $chanleObj = $class->newInstance();
        } catch (\ReflectionException $e) {
            $chanleObj = null;
        }
        $this->chanleObj = $chanleObj;
    }
        
    /**
     * 创建订单
     *
     * @return void
     */
    public function create()
    {
        $param = $this->chanleObj->getOrderParam();
        var_dump($param);
        // todo 拿到订单参数，创建订单
    }
    
    /**
     * 取消订单
     *
     * @return void
     */
    public function cancel()
    {
        $param = $this->chanleObj->getCancelParam();
        var_dump($param);
        // todo 拿到取消订单参数，取消订单
    }

    /**
     * 推送物流
     *
     * @return void
     */
    public function pushShip()
    {
        $param = $this->chanleObj->getShipParam();
        var_dump($param);
        // todo 拿到物流参数，推送物流
    }
}
